
#ifndef __3DCAMERA_H__
#define __3DCAMERA_H__

#include "3dModelDef.h"

class C3dCamera
{
public:

	C3dCamera()
	{
	}

	virtual ~C3dCamera()
	{
	}

	int Init(int cam_attr,			// attributes
			CPoint4d& cam_pos,		// initial camera position
			CVector4d& cam_dir,		// initial camera angles
			CPoint4d& cam_target,	// UVN target
			float near_clip_z,		// near and far clipping planes
			float far_clip_z,
			float fov,				// field of view in degrees
			float viewport_width,	// size of final screen viewport
			float viewport_height);

	int Build_Matrix_Euler(int cam_rot_seq);
	int Build_Matrix_UVN(int mode);

	int Build_Perspective_MATRIX4X4(CMatrix44& m);


	//
	int			m_state;		// state of camera
	int			m_attr;			// camera attributes

	CPoint4d	m_pos;			// world position of camera used by both camera models

	CVector4d	m_dir;			// angles or look at direction of camera for simple 
	// euler camera models, elevation and heading for
	// uvn model

	CVector4d	m_u;			// extra vectors to track the camera orientation
	CVector4d	m_v;			// for more complex UVN camera model
	CVector4d	m_n;        

	CVector4d	m_target;		// look at target

	float		m_view_dist;	// focal length 

	float		m_fov;          // field of view for both horizontal and vertical axes

	// 3d clipping planes
	// if view volume is NOT 90 degree then general 3d clipping
	// must be employed
	float		m_near_clip_z;		// near z=constant clipping plane
	float		m_far_clip_z;      // far z=constant clipping plane

	CPlane3d	m_rt_clip_plane;  // the right clipping plane
	CPlane3d	m_lt_clip_plane;  // the left clipping plane
	CPlane3d	m_tp_clip_plane;  // the top clipping plane
	CPlane3d	m_bt_clip_plane;  // the bottom clipping plane                        

	float		m_viewplane_width;     // width and height of view plane to project onto
	float		m_viewplane_height;    // usually 2x2 for normalized projection or 
	// the exact same size as the viewport or screen window

	// remember screen and viewport are synonomous 
	float		m_viewport_width;     // size of screen/viewport
	float		m_viewport_height;
	float		m_viewport_center_x;  // center of view port (final image destination)
	float		m_viewport_center_y;

	// aspect ratio
	float		m_aspect_ratio;

	// these matrices are not necessarily needed based on the method of
	// transformation, for example, a manual perspective or screen transform
	// and or a concatenated perspective/screen, however, having these 
	// matrices give us more flexibility         

	CMatrix44	m_mcam;   // storage for the world to camera transform matrix
	CMatrix44	m_mper;   // storage for the camera to perspective transform matrix
	CMatrix44	m_mscr;   // storage for the perspective to screen transform matrix
};

#endif